#include<stdio.h>
int main()
{
    //freopen("in.txt","r",stdin);
    int n;
    scanf("%d",&n);
    int ans = -999999;
    int  pre = 1000000000;
    int now;
    for(int i = 0; i < n; i++)
    {
        scanf("%d",&now);
        if(now - pre > ans) ans = now - pre;
        if(pre > now) pre = now;
    }
    printf("%d",ans);
}